def test(x):
    "我写的第一个python函数"
    print('hello function\n'*x)
    i=x
    return i
a=test(10)

print("------------传不可变参数--------------")
def ChangeInt(a):
    a = 10
b = 2
ChangeInt(b)
print(b)

print("------------传可变参数--------------")
def changeme(mylist):
    "修改传入的列表"
    mylist.append([1, 2, 3, 4]);
    print("函数内取值: ", mylist)
    return
# 调用changeme函数
mylist = [10, 20, 30];
changeme(mylist);
print("函数外取值: ", mylist)

print("------------参数可以不设置--------------")
def test():
    print('hello function\n')
    return
a=test()

print("------------关键字参数--------------")
def printme(str):
    "打印任何传入的字符串"
    print(str);
    return
printme(str="My string");

'''
如果关键字名称不一致会报错,错误范例:
def printme(st):
...
printme(str="My string");
'''
print("------------默认值--------------")
def setage(name,age=18):
    "打印任何传入的字符串"
    print(name,'的年龄是',age)
    return
name='张三'
setage(name,);

print("------------不定长参数--------------")
def sethobby(hobby,*hobbiys):
    "打印任何传入的字符串"
    print("我最大的爱好是",hobby,"除此之外,我还有这些爱好:")
    for var in hobbiys:
        print(var)
    return
#输入你的爱好,排名分先后,至少选择一个
sethobby('吃饭','睡觉','编程');

print("------------匿名函数--------------")
setResult =lambda math,chemistry :math+chemistry
print(setResult(99,100));

print("------------不写return语句--------------")
def noRet():
    print(1+1);
noRet()

print("------------返回值为空--------------")
def retNull():
    print(3)
    return
retNull()